package cn.clouds234.liteflow;

import cn.clouds234.liteflow.context.MainContext;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.core.FlowExecutorHolder;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.property.LiteflowConfig;

import java.util.Arrays;

/**
 * @author wyf
 * @date 2025/3/3 16:31
 */
public class Client {
    public static void main(String[] args) {
        // 初始化规则链
        LiteflowConfig config = new LiteflowConfig();
        config.setRuleSource("conf/liteflow.xml");
        FlowExecutor flowExecutor = FlowExecutorHolder.loadInstance(config);
        // 定义需要执行的节点
        MainContext mainContext = new MainContext();
        mainContext.setChain(Arrays.asList("c","b","a"));
        // 执行并获取结果
        LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg", mainContext);
        String message = response.getMessage();
        String executeStepStr = response.getExecuteStepStr();
        System.out.println(message);
        System.out.println(executeStepStr);
    }
}
